{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "ec963e76",
   "metadata": {},
   "source": [
    "# 周边搜索\n",
    "* url\n",
    "https://restapi.amap.com/v3/staticmap?parameters\n",
    "\n",
    " 请求参数（两类）\n",
    "* 1.按照关键词搜索\n",
    "* 2. 按照查询POI 类型(分类表—下载）\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "1ef7a863",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'113.678280,23.628439'"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import requests\n",
    "geo_url = \"https://restapi.amap.com/v3/geocode/geo?parameters\"\n",
    "payload = {\n",
    "    \"key\":\"c32566670faf404dfa55e752848209f5\",\n",
    "    \"address\":\"广东省广州市从化区广州南方学院\"\n",
    "}\n",
    "r = requests.get(url=geo_url, params=payload)\n",
    "广州南方学院_location = r.json()['geocodes'][0]['location']\n",
    "广州南方学院_location"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1e98d7bc",
   "metadata": {},
   "source": [
    "# 1.关键词搜索"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "3b9429a2",
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "817175c3",
   "metadata": {},
   "outputs": [],
   "source": [
    "around_url ='https://restapi.amap.com/v5/place/text?parameters'\n",
    "\n",
    "payload = {\n",
    "    'key':'c32566670faf404dfa55e752848209f5',\n",
    "    'location':广州南方学院_location,\n",
    "    'keywords':'美食'\n",
    "}\n",
    "r = requests.get(around_url,params = payload)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "9f20fec6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'status': '1',\n",
       " 'info': 'OK',\n",
       " 'infocode': '10000',\n",
       " 'pois': [{'name': '幸福楼酒店(温泉东路)',\n",
       "   'id': 'B00140FG8A',\n",
       "   'location': '113.654186,23.644836',\n",
       "   'type': '餐饮服务;中餐厅;中餐厅',\n",
       "   'typecode': '050100',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '从化区',\n",
       "   'address': '温泉镇温泉东路99号',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440117'},\n",
       "  {'name': '海景农庄',\n",
       "   'id': 'B00141JCOM',\n",
       "   'location': '113.759552,23.620845',\n",
       "   'type': '餐饮服务;中餐厅;中餐厅',\n",
       "   'typecode': '050100',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '从化区',\n",
       "   'address': '934县道西50米',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440117'},\n",
       "  {'name': '荔香园(员工之家东北)',\n",
       "   'id': 'B00140UI8N',\n",
       "   'location': '113.716369,23.699699',\n",
       "   'type': '餐饮服务;中餐厅;中餐厅',\n",
       "   'typecode': '050100',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '从化区',\n",
       "   'address': '良口镇御泉大道353号',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440117'},\n",
       "  {'name': '椰林海鲜码头(从化店)',\n",
       "   'id': 'B0FFG6ZL2Q',\n",
       "   'location': '113.615544,23.556313',\n",
       "   'type': '餐饮服务;中餐厅;海鲜酒楼',\n",
       "   'typecode': '050119',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '从化区',\n",
       "   'address': '环市东路666号(凯景酒店紧邻)',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440117'},\n",
       "  {'name': '迎宾农庄',\n",
       "   'id': 'B00140W52Q',\n",
       "   'location': '113.615916,23.565717',\n",
       "   'type': '餐饮服务;中餐厅;中餐厅',\n",
       "   'typecode': '050100',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '从化区',\n",
       "   'address': '江村迎宾大道',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440117'},\n",
       "  {'name': '麦当劳(从化新世纪广场分店餐厅)',\n",
       "   'id': 'B00140BNGX',\n",
       "   'location': '113.588681,23.547759',\n",
       "   'type': '餐饮服务;快餐厅;麦当劳',\n",
       "   'typecode': '050302',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '从化区',\n",
       "   'address': '新城路68号新世纪广场1层',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440117'},\n",
       "  {'name': '肯德基(广州新世纪餐厅)',\n",
       "   'id': 'B00140TWK0',\n",
       "   'location': '113.587817,23.547716',\n",
       "   'type': '餐饮服务;快餐厅;肯德基',\n",
       "   'typecode': '050301',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '从化区',\n",
       "   'address': '新城东路66号林苑大厦1-2层',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440117'},\n",
       "  {'name': '南海食街(从化城区总店)',\n",
       "   'id': 'B00140HTH8',\n",
       "   'location': '113.605662,23.526272',\n",
       "   'type': '餐饮服务;中餐厅;中餐厅',\n",
       "   'typecode': '050100',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '从化区',\n",
       "   'address': '江埔街环市东路138号',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440117'},\n",
       "  {'name': '仙庙烧鸡(商贸城店)',\n",
       "   'id': 'B0FFHHJ590',\n",
       "   'location': '113.603929,23.529473',\n",
       "   'type': '餐饮服务;中餐厅;广东菜(粤菜)',\n",
       "   'typecode': '050103',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '从化区',\n",
       "   'address': '利源路40号',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440117'},\n",
       "  {'name': '春景酒家',\n",
       "   'id': 'B0FFFYNBJ1',\n",
       "   'location': '113.603134,23.545983',\n",
       "   'type': '餐饮服务;中餐厅;综合酒楼',\n",
       "   'typecode': '050101',\n",
       "   'pname': '广东省',\n",
       "   'cityname': '广州市',\n",
       "   'adname': '从化区',\n",
       "   'address': '江埔街河东北路79号之四、五、六号',\n",
       "   'pcode': '440000',\n",
       "   'citycode': '020',\n",
       "   'adcode': '440117'}],\n",
       " 'count': '10'}"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ede9d706",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
